package com.twu.biblioteca;

import java.util.Arrays;
import java.util.List;

public abstract class Collection {
    List<Item> items;

    public Collection(Item... items) {
        this.items = Arrays.asList(items);
    }

    public boolean checkOut(String itemToBeCheckedOut) {
        for (Item item : this.items) {
            if (item.name.equals(itemToBeCheckedOut)) {
                return item.checkOut();
            }
        }
        return false;
    }

    public boolean checkIn(String itemToBeReturned) {
        for (Item item : this.items) {
            if (item.matches(itemToBeReturned)) {
                return item.checkIn();
            }
        }
        return false;
    }

    public abstract String toString();
}
